#include<bits/stdc++.h>
#define ll long long
#define L x<<1
#define R L|1
#define mid (l+r>>1)
#define lc L,l,mid
#define rc R,mid+1,r
#define OK Ll<=l&&r<=Rr
#define Root 1,1,n
#define rep(x,y,z) for(int x=(y);x<=(z);x++)
#define per(x,y,z) for(int x=(y);x>=(z);x--)
#define repn(x) rep(x,1,n)
#define repm(x) rep(x,1,m)
#define pb push_back
#define e(x) for(int i=h[x],y=to[i];i;i=nxt[i],y=to[i])
#define E(x) for(auto y:p[x])
#define Pi pair<int,int>
#define ui unsigned ll
inline int read(){int s=0,w=1;char c=getchar();while(c<48||c>57) {if(c=='-') w=-1;c=getchar();}while(c>=48&&c<=57)s=(s<<1)+(s<<3)+c-48,c=getchar();return s*w;}
inline void pf(ll x){if(x<0) putchar('-'),x=-x;if(x>9)pf(x/10);putchar(x%10+48);}
using namespace std;
const int N =1e6+5,M=6e6+5,inf=(1LL<<31)-1,mod=998244353;
const ll llf=1e18;
inline void add(int &a,int b){((a+=b)>=mod) and (a-=mod);}
inline int Add(int a,int b){return add(a,b),a;}
inline int mul(int a,int b){return 1LL*a*b%mod;}
inline void Mul(int &a,int b){a=mul(a,b);}
inline void red(int &a,int b){add(a,mod-b);}
inline int Red(int a,int b){return red(a,b),a;}
inline int qp(int a,int b){if(!b)return 1;int c=qp(a,b>>1);Mul(c,c);if(b&1)Mul(c,a);return c;}
inline int INV(int x){return qp(x,mod-2);}
int n,m,a,b,h[N],to[M],nxt[M],cnt,w[M],tot;
inline void add_(int a,int b,int c){
	to[++cnt]=b,nxt[cnt]=h[a],h[a]=cnt,w[cnt]=c;
}
vector<int>p[N];
ll dis[N];
inline void sol(int s){
	repn(i)dis[i]=inf;
	queue<int>q;
	dis[s]=0,q.push(s);
	while(!q.empty()){
		int x=q.front();q.pop();
		if(dis[x]==1)add_(s,x,a);
		if(dis[x]==2){
			add_(s,x,b);
			continue;
		}
		E(x)if(dis[y]>dis[x]+1)dis[y]=dis[x]+1,q.push(y);
	}
}
struct node{
	int x;
	ll d;
	bool friend operator<(node a,node b){
		return a.d>b.d;
	}
};
bool vis[N];
inline void dijk(){
	rep(i,1,tot)dis[i]=llf;
	priority_queue<node>q;
	dis[1]=0,q.push({1,0});
	while(!q.empty()){
		int x=q.top().x;q.pop();
		if(vis[x])continue;
		vis[x]=1;
		e(x)if(dis[y]>dis[x]+w[i])dis[y]=dis[x]+w[i],q.push({y,dis[y]});
	}
}
inline void dfs(int x,int fa){
	int k=++tot;
	E(x)if(y^fa){
		dfs(y,x);
		add_(x,y,a),add_(y,x,a);
		add_(y,k,0),add_(k,y,b);
		for(auto z:p[y])if(z^x)add_(x,z,b),add_(z,x,b);
	}
}
inline void subtask0(){
	repn(i)sol(i);
	dijk();
	rep(i,2,n)pf(dis[i]),putchar('\n');
}
inline void subtask1(){
	dfs(1,0);
	dijk();
	rep(i,2,n)pf(dis[i]),putchar('\n');
}
inline void Main(){
	tot=n=read(),m=read(),a=read(),b=read();
	repm(o){
		int x=read(),y=read();
		p[x].pb(y),p[y].pb(x);
	}
	if(m<=1000)return subtask0(),void();
	return subtask1(),void();
}
signed main(){
	freopen("edge.in","r",stdin);
	freopen("edge.out","w",stdout); 
	int T=1;
	while(T--)Main(); 
	return 0;
}
